package com.fluxtah.jordl.examples.twitter;

import com.fluxtah.jordl.lib.TransformerProvider;
import com.fluxtah.jordl.lib.TransformException;
import com.fluxtah.jordl.lib.HttpRequestHelper;
import com.fluxtah.jordl.lib.WebResponse;
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;
import android.net.Uri;

public class GetStatusRequest {
	
	private static final String PATH="/statuses/show.json";
	
	private String idParam;
	private Boolean trimUserParam;
	private Boolean includeEntitiesParam;
	
	public void setIdParam(String value) {
		this.idParam = value;
	}
	public void setTrimUserParam(Boolean value) {
		this.trimUserParam = value;
	}
	public void setIncludeEntitiesParam(Boolean value) {
		this.includeEntitiesParam = value;
	}
	
	public GetStatusRequest(){
	}
	
	public String createUrl(){
		Uri.Builder uriBuilder = Uri.parse(PATH).buildUpon();
		if(idParam != null){
			uriBuilder.appendQueryParameter("id", idParam.toString());
		}
		if(trimUserParam != null){
			uriBuilder.appendQueryParameter("trim_user", trimUserParam.toString());
		}
		if(includeEntitiesParam != null){
			uriBuilder.appendQueryParameter("include_entities", includeEntitiesParam.toString());
		}

		return uriBuilder.toString();
	}
	
	protected GetStatusResponse createResponse(String baseUrl, HttpRequestHelper requestHelper, TransformerProvider transformerProvider)
		throws ClientProtocolException, IOException, TransformException {
		String url = baseUrl + createUrl();
		WebResponse response = requestHelper.getJson(url);
		
		return new GetStatusResponse(transformerProvider, response);
	}
}	
